//
//  BIZStarGradeView.m
//  biz
//
//  Created by 小龙 on 2017/4/7.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "BIZStarGradeView.h"
@interface BIZStarGradeView()
@property (nonatomic, strong) UIImageView *starImageView;
@property (nonatomic) CGSize starImageSize;
@property (nonatomic, assign) float starPadding;
@end
@implementation BIZStarGradeView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        [self buildDataAndUI];
    }
    return self;
    
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    if (self = [super initWithCoder:aDecoder]) {
        [self buildDataAndUI];
    }
    return self;
}

#pragma mark - Private Methods

- (void)buildDataAndUI {
    self.backgroundColor = [UIColor lightGrayColor];
    NSInteger count = 0;
    if (_numberOfStars>0) {
        count = _numberOfStars;
    }
    else {
        count = 5;
    }
    
    for (int i = 0; i <count; i++) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.frame = CGRectMake(i*(self.starImageSize.width + self.starPadding), 0, self.starImageSize.width, self.starImageSize.height);
        self.starImageView = imageView;
        [self addSubview:self.starImageView];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
}


-(void)setStarImageName:(NSString *)starImageName
{
    _starImageName = [starImageName copy];
    self.starImageView.image = [UIImage imageNamed:starImageName];
}

- (void)setStartSize:(CGSize)startSize
{
    _startSize = startSize;
    self.starImageSize = startSize;
}

- (void)setPadding:(float)padding
{
    _padding = padding;
    self.starPadding = padding;
}

@end
